<?php

/*
    author: dkloz
    A function that applies the filters for each entity in this category.
    Each attribute has to be between max and min in order for its id to be on
    the array to be returned
    We must have N elements in the max/min arrays if N is the number of attributes
    that can be measured
    STATUS: Not READY
*/
function BL_applyFilters($category, $maxs, $mins)
{

    $counter = 0;
    $entities_ids = array();
    $entities = DB_getEntities($category);

    /*for every entity, checks if all its attributes are within the range.
    If they are it adds its id to the array to be returned*/
    foreach ($entities as $ent)
    {

        $attrs_passed = 0;
        $i = 0;
        foreach ($entities->GetAttributes() as $attr)
        {

            if ($attr->GetType() == "i")
            { ///?????? pws legete to type pou sigirnete? :D
                if ($attr->GetValue() > $maxs[$i] || $attr->GetValue() < $mins[$i])
                {
                    break;
                }
                $i++;

            }
            $attrs_passed++;
        }

        /*If all the entities passed the test*/
        if ($attrs_passed == sizeof($entities->GetAttributes()))
        {
            $entities_ids[$counter] = $ent->GetId(); //add it to the array
        }
    }

    return $entities_ids;
}

?>